package cn.luischen.aspect;

import static org.junit.Assert.assertTrue;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import cn.luischen.service.log.LogService;

/**
 * The class <code>WebLogAspectTest</code> contains tests for the class
 * <code>{@link WebLogAspect}</code>.
 * <p>
 * Copyright (c) 2020
 * 
 * @generatedBy UnitSpirit at 2020-04-13 17:31:56
 * @author Administrator
 * @version $Revision: 1.0.0
 */
@RunWith(PowerMockRunner.class)
public class WebLogAspect_WGTest2 {

	@InjectMocks
	WebLogAspect unitspirit_mock_instance;
	@Mock
	LogService mock_LogService;

	@Test
	@PrepareForTest({ ServletRequestAttributes.class, RequestContextHolder.class })

	public void test_doBefores() throws Throwable {

		PowerMockito.mockStatic(RequestContextHolder.class);
		ServletRequestAttributes mock_ServletRequestAttributes = PowerMockito.mock(ServletRequestAttributes.class);
		HttpServletRequest mock_HttpServletRequest = PowerMockito.mock(HttpServletRequest.class);
		HttpSession mock_HttpSession = PowerMockito.mock(HttpSession.class);
		PowerMockito.when(mock_HttpServletRequest, "getSession").thenReturn(mock_HttpSession);
		PowerMockito.when(mock_HttpServletRequest, "getRequestURL").thenReturn(new StringBuffer("getRequestURL"));
		PowerMockito.when(mock_HttpServletRequest, "getMethod").thenReturn("getMethod");
		PowerMockito.when(mock_HttpServletRequest, "getRemoteAddr").thenReturn("getRemoteAddr");

		// final 方法
		PowerMockito.when(mock_ServletRequestAttributes, "getRequest").thenReturn(mock_HttpServletRequest);
		// 静态方法
		PowerMockito.when(RequestContextHolder.class, "getRequestAttributes").thenReturn(mock_ServletRequestAttributes);


		org.aspectj.lang.JoinPoint JoinPoint_p_0 = PowerMockito.mock(org.aspectj.lang.JoinPoint.class);

		org.aspectj.lang.Signature Signature_p_0 = PowerMockito.mock(org.aspectj.lang.Signature.class);
		PowerMockito.when(Signature_p_0, "getDeclaringTypeName").thenReturn("getDeclaringTypeName");
		PowerMockito.when(Signature_p_0, "getName").thenReturn("getName");

		PowerMockito.when(JoinPoint_p_0, "getSignature").thenReturn(Signature_p_0);
		PowerMockito.when(JoinPoint_p_0, "getArgs").thenReturn(new String[] { "1", "2" });
		
		unitspirit_mock_instance.doBefore(JoinPoint_p_0);
		assertTrue(true);
	}

	@org.junit.Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
		try {
			MockitoAnnotations.initMocks(this);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}